/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   Module Name          : com.yaodian100.core.batch.service.impl.BatchJobServiceImpl
   Module Description   :

   Date Created      : 2009/12/3
   Original Author   : andy.chuang
   Team              : yaodian100
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   MODIFICATION HISTORY
   ------------------------------------------------------------------------------
   Date Modified       Modified by       Comments
   ------------------------------------------------------------------------------
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
package com.yaodian100.core.batch.service.impl;

import java.util.Date;

import javax.annotation.Resource;

import org.springframework.transaction.annotation.Transactional;

import com.yaodian100.core.batch.dao.BatchJobDao;
import com.yaodian100.core.batch.entity.BatchJob;
import com.yaodian100.core.batch.service.BatchJobService;
import com.yaodian100.core.common.exception.CoreException;
import com.yaodian100.core.common.service.impl.DomainServiceImpl;

/**
 * @author andy.chuang
 * 
 */
public class BatchJobServiceImpl extends DomainServiceImpl<BatchJob> implements BatchJobService {
	@Resource
	private BatchJobDao batchJobDao;

	@Transactional(readOnly = false)
	public void save(String beanId, String parameters) throws CoreException {
		save(beanId, parameters, null);
	}

	@Transactional(readOnly = false)
	public void save(String beanId, String parameters, Date startDate) throws CoreException {
		BatchJob bj = new BatchJob(beanId, parameters);
		if (startDate != null) {
			bj.setStartDate(startDate);
		}
		batchJobDao.save(bj);
	}

	@Transactional(readOnly = false)
	public void save(String beanId, String parameters, Date startDate, String jobKey) throws CoreException {
		BatchJob bj = new BatchJob(beanId, parameters);
		bj.setJobKey(jobKey);
		if (startDate != null) {
			bj.setStartDate(startDate);
		}
		batchJobDao.save(bj);
	}
}
